//
//  Event.m
//  ObjCAS
//
//  Created by Colin Leung on 19/05/2010.
//  Copyright 2010 Digi3 Studio. All rights reserved.
//

#import "Event.h"
@implementation Event

static NSString * const EVENT_ACTIVATE = @"activate";
static NSString * const EVENT_ADDED = @"added";
static NSString * const EVENT_ADDED_TO_STAGE = @"addedToStage";
static NSString * const EVENT_CANCEL = @"cancel";
static NSString * const EVENT_CHANGE = @"change";
static NSString * const EVENT_CLEAR = @"clear";
static NSString * const EVENT_CLOSE = @"close";
static NSString * const EVENT_CLOSING = @"closing";
static NSString * const EVENT_COMPLETE = @"complete";
static NSString * const EVENT_CONNECT = @"connect";
static NSString * const EVENT_COPY = @"copy";
static NSString * const EVENT_CUT = @"cut";
static NSString * const EVENT_DEACTIVATE = @"deactivate";
static NSString * const EVENT_DISPLAYING = @"displaying";
static NSString * const EVENT_ENTER_FRAME = @"enterFrame";
static NSString * const EVENT_EXIT_FRAME = @"exitFrame";
static NSString * const EVENT_EXITING = @"exiting";
static NSString * const EVENT_FRAME_CONSTRUCTED = @"frameConstructed";
static NSString * const EVENT_FULLSCREEN = @"fullScreen";
static NSString * const EVENT_HTML_BOUNDS_CHANGE = @"htmlBoundsChange";
static NSString * const EVENT_HTML_DOM_INITIALIZE = @"htmlDOMInitialize";
static NSString * const EVENT_HTML_RENDER = @"htmlRender";
static NSString * const EVENT_ID3 = @"id3";
static NSString * const EVENT_INIT = @"init";
static NSString * const EVENT_LOCATION_CHANGE = @"locationChange";
static NSString * const EVENT_MOUSE_LEAVE = @"mouseLeave";
static NSString * const EVENT_NETWORK_CHANGE = @"networkChange";
static NSString * const EVENT_OPEN = @"open";
static NSString * const EVENT_PASTE = @"paste";
static NSString * const EVENT_REMOVED = @"removed";
static NSString * const EVENT_REMOVED_FROM_STAGE = @"removedFromStage";
static NSString * const EVENT_RENDER = @"render";
static NSString * const EVENT_RESIZE = @"resize";
static NSString * const EVENT_SCROLL = @"scroll";
static NSString * const EVENT_SELECT = @"select";
static NSString * const EVENT_SELECT_ALL = @"selectAll";
static NSString * const EVENT_SOUND_COMPLETE = @"soundComplete";
static NSString * const EVENT_TAB_CHILDREN_CHANGE = @"tabChildrenChange";
static NSString * const EVENT_TAB_ENABLED_CHANGE = @"tabEnabledChange";
static NSString * const EVENT_TAB_INDEX_CHANGE = @"tabIndexChange";
static NSString * const EVENT_UNLOAD = @"unload";
static NSString * const EVENT_USER_IDLE = @"userIdle";
static NSString * const EVENT_USER_PRESENT = @"userPresent";

@synthesize bubbles;
@synthesize cancelable;
@synthesize currentTarget;
@synthesize eventPhase;
@synthesize target;
@synthesize type;

- (Event*)initWithType:(NSString*)_type{
	return [self initWithType:_type bubbles:NO cancelable:NO];
}

-(Event*) initWithType:(NSString*)_type bubbles:(BOOL)_bubbles cancelable:(BOOL)_cancelable{
	if((self = [super init])){
		type = _type;
		bubbles = _bubbles;
		cancelable = _cancelable;
		eventPhase = 2;
	}
	return self;	
}

- (NSString*) toString{
	return [[[NSString alloc] initWithFormat:@"[Event type='%@' bubbles=%i cancelable=%i eventPhase=%i]", type, bubbles, cancelable, eventPhase] autorelease];
}

-(void)dealloc{
	[currentTarget release];
	[target release];
	[super dealloc];
}
@end
